package com.chenglu.android.orderinfo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.LogUtils;
import com.chenglu.android.common.utils.ToastUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.orderinfo.bean.OrderDetailBean;
import com.chenglu.android.orderinfo.bean.QrCodeListBean;

import java.util.List;


/**
 * @author: lyj
 * @Created: by Copyright 2023/3/29 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：订单的核销码
 */
public class QrcodeListAdapter extends BaseQuickAdapter<QrCodeListBean.QrCodeList, BaseViewHolder> {

    Context mContext;

    public QrcodeListAdapter(Context context,int layoutResId, @Nullable List<QrCodeListBean.QrCodeList> data) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper,QrCodeListBean.QrCodeList item) {

        if(item == null){
            return;
        }

        LogUtils.e("item---");
        helper.setText(R.id.tv_qrcode,item.getName());
        ImageView imageView = helper.getView(R.id.iv_qr_code);

        switch (item.getStatus()){
            case 0:
                helper.setText(R.id.tv_use_time,item.getUseTime())
                .setGone(R.id.tv_use_time,false);
                helper.setText(R.id.tv_use_status,"已失效");
                imageView.setBackground(mContext.getResources().getDrawable(R.drawable.icon_code_use));
                break;
            case 1:
                helper.setText(R.id.tv_use_time,item.getUseTime())
                        .setGone(R.id.tv_use_time,false);
                helper.setText(R.id.tv_use_status,"待使用");
                imageView.setBackground(mContext.getResources().getDrawable(R.drawable.icon_code_waituse));
                break;
            case 2:
                helper.setText(R.id.tv_use_time,item.getUseTime())
                        .setGone(R.id.tv_use_time,true);
                helper.setText(R.id.tv_use_status,"已使用");
                imageView.setBackground(mContext.getResources().getDrawable(R.drawable.icon_code_use));
                break;
        }
    }

}
